Skip to content

Stable 26.3 Backport of #131001 - Reuse the GCM cipher context between rows in encrypt/decrypt - #2899

Merged
zvonand merged 2 commits into
stable-26.3from
backports/stable-26.3/131001
Nov 18, 2026
Merged

zvonand merged 2 commits into
stable-26.3from
backports/stable-26.3/131001

Conversation

@blau-ai

@blau-ai blau-ai commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • Performance Improvement

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

Improve performance of the encrypt, decrypt and tryDecrypt functions in AES-GCM modes by up to 27x with many threads. (ClickHouse#131001 by @mkmkme)

Documentation entry for user-facing changes

...

CI/CD Options

Exclude tests:

  • Fast test
  • Integration Tests
  • Stateless tests
  • Stateful tests
  • Unit tests
  • Performance tests
  • Aarch64 tests
  • All with ASAN
  • All with TSAN
  • All with MSAN
  • All with UBSAN
  • All with Coverage
  • All Regression
  • Disable CI Cache

Regression jobs to run:

  • Fast suites (mostly <1h)
  • Aggregate Functions (2h)
  • Alter (1.5h)
  • Benchmark (30m)
  • CAS (content-addressed storage; Antalya only)
  • ClickHouse Keeper (1h)
  • Iceberg (2h)
  • LDAP (1h)
  • OAuth (5m)
  • Parquet (1.5h)
  • RBAC (1.5h)
  • SSL Server (1h)
  • S3 (2h)
  • S3 Export (2h)
  • Swarms (30m)
  • Tiered Storage (2h)

alexey-milovidov and others added 2 commits November 18, 2026 11:52
Reuse the GCM cipher context between rows in encrypt/decrypt

Conflicts committed as-is; the next commit resolves them:
- src/Functions/FunctionsAES.h (both modified)
Took the PR's declarations of `key_holder` and `ctx_key_state` in the decrypt path.
@blau-ai

blau-ai commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

Port-AL: cherry-pick conflicts resolved by AI

Conflicted files:

  • src/Functions/FunctionsAES.h (both modified)

Commits:

  • bf2effa: cherry-pick with the conflicts committed as-is

  • 126e274: resolution

  • The conflict was a single hunk in the decrypt function of src/Functions/FunctionsAES.h, at the declarations of key_holder and ctx_key_state.

  • stable-26.3 had KeyHolder<mode> key_holder; and [[maybe_unused]] CachedKeyState ctx_key_state;. The [[maybe_unused]] was there because only the non-GCM modes used the state.

  • I used the PR's KeyHolder<mode> key_holder{}; and CachedKeyState ctx_key_state;. The GCM branches now use ctx_key_state, so the attribute is no longer needed. The {} form matches the other KeyHolder declarations in the file.

@github-actions

Copy link
Copy Markdown

Workflow [PR], commit [126e274]

@zvonand

zvonand commented Nov 18, 2026

Copy link
Copy Markdown
Member

@blau-ai

@blau-ai

blau-ai commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

CI triage for 126e2748

Verdict: none of the failures come from this PR. There are 4 failure groups: 2 are CI-wide infra problems, 1 is a policy check that every backport fails, and 1 is an image CVE scan affected by external changes. The AES-GCM change (src/Functions/FunctionsAES.h plus tests) didn't break anything. Every stateless suite that ran (amd debug, asan, ubsan, distributed plan, s3 storage) and the asan/ubsan unit tests show 0 failures. All builds pass, and so do the fuzzers.

Check Classification PR-caused?
Integration tests (amd_binary 2/5, 4/5; amd_asan old analyzer 3/8, 5/8) — 40 tests Infra: python-bottle:latest image arch flip, open issue #2879 No
Grype Scan (keeper, server-alpine) — 4 High CVEs External: base image / vulnerability DB No
DCO Policy: the upstream merge commit has no Signed-off-by No
SQLLogic test, PR Still pending n/a

1. Integration tests: test_storage_s3/test_sts.py (3) and test_database_glue/test.py (17), failing on both amd_binary and amd_asan

All 40 failures happen in cluster.start(), before any test body runs. The mock STS container cannot run the mounted clickhouse binary:

E   Exception: Timed out while waiting for instance `sts.us-east-1.amazonaws.com' with ip address 172.16.3.8 to start. ...
E   bash: line 1: /usr/bin/clickhouse: cannot execute: required file not found

2. Grype Scan: clickhouse-keeper and clickhouse-server …-alpine, "4 high/critical vulnerabilities"

3. DCO

4. Pending

SQLLogic test (and the aggregate PR status) were still running when I looked.


One caveat: the praktika report leaves out passing tests, so I couldn't confirm a per-test entry for 04337_encrypt_decrypt_block_modes. The suites that run it all report Failed: 0.

No changes pushed, because nothing in this PR needs fixing.

@zvonand zvonand added the verified Approved for release label Nov 18, 2026
@zvonand
zvonand merged commit 4b57406 into stable-26.3 Nov 18, 2026
262 of 277 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

26.3 backport Backport stable verified Approved for release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants